
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Spring WebFlux实现高并发WebService - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>Spring WebFlux实现高并发WebService - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">在高并发场景下，传统的Spring MVC架构会暴露出哪些主要问题，而Spring WebFlux是如何解决这些问题的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">在电商秒杀等高并发场景中，传统同步阻塞的Spring MVC架构会暴露出线程资源耗尽和响应延迟攀升等问题。Spring WebFlux通过非阻塞I/O和事件驱动模型，为这些场景提供了全新的解决方案。</div>
          </div>
          <div class="card-source">来源: 一、引言：高并发场景下的技术挑战与响应式编程的崛起</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Spring WebFlux是如何通过其非阻塞I/O模型实现单线程处理多个请求的，这种设计带来了什么好处？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">WebFlux基于Netty等异步服务器，采用事件循环模型（Event Loop）。每个请求由事件循环线程处理，通过`Selector`监听多路复用通道，从而实现单线程处理多请求的并发模型。这种设计将线程切换开销从O(n)降低到O(1)，显著提升了资源利用率。</div>
          </div>
          <div class="card-source">来源: 2.1 非阻塞I/O的底层原理</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">核心概念</div>
          <div class="card-question">请解释响应式流中的`Mono`和`Flux`有什么区别，并分别举例说明它们的应用场景。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">核心概念</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">`Mono`和`Flux`是响应式流的两种核心类型。`Mono`表示0-1个元素的异步序列，适用于返回单个对象的场景（如查询用户详情）。`Flux`表示0-N个元素的异步序列，适用于返回集合数据的场景（如获取商品列表）。</div>
          </div>
          <div class="card-source">来源: 2.2 响应式流的数据处理范式</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在使用Spring Initializr创建WebFlux项目时，必须添加的核心依赖是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">创建WebFlux项目时，必须添加的核心依赖是 `spring-boot-starter-webflux`。</div>
          </div>
          <div class="card-source">来源: 3.1 项目初始化</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">优化</div>
          <div class="card-question">在WebFlux实战中，为了实现非阻塞的数据库访问，推荐使用什么技术来替代传统的JDBC？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">优化</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">推荐使用R2DBC（Reactive Relational Database Connectivity）来替代JDBC，以实现非阻塞的数据库访问。</div>
          </div>
          <div class="card-source">来源: 4.2.3 性能优化</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">实践</div>
          <div class="card-question">在编写响应式代码时，应如何处理需要延时的操作（例如替代`Thread.sleep()`）以避免阻塞事件循环线程？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">实践</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">应该禁用`Thread.sleep()`，并改用响应式的`Mono.delay()`来实现延时操作，这样可以避免阻塞线程。</div>
          </div>
          <div class="card-source">来源: 5.1 避免阻塞操作的黄金法则</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">排错</div>
          <div class="card-question">如果在WebFlux应用中出现内存溢出日志，可能的原因是什么？文档中提到了哪种操作符用于解决此问题？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">排错</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">出现内存溢出日志的可能原因是未正确处理背压（Backpressure）。文档中提到可以使用`onBackpressureBuffer()`操作符来解决这个问题。</div>
          </div>
          <div class="card-source">来源: 6.1 常见错误类型</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在对WebFlux应用进行单元测试时，文档推荐使用哪种工具来验证响应式流（Reactive Stream）的处理逻辑？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">文档推荐通过`StepVerifier`来对响应式链进行单元测试。</div>
          </div>
          <div class="card-source">来源: 6.2 调试技巧</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">调试</div>
          <div class="card-question">在调试WebFlux应用时，如何启用Reactor的详细调试模式以获取更丰富的错误信息？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">调试</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">可以通过启用JVM参数 `-Dreactor.debug.enabled=true` 来获取详细的调试信息。</div>
          </div>
          <div class="card-source">来源: 6.2 调试技巧</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
